package cn.yuanqiao.archive.appManager.domain;

import cn.yuanqiao.common.annotation.Excel;
import cn.yuanqiao.common.annotation.IdAnnotation;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 业务档案门类对象 YQDA_CATEGORY
 *
 * @author yuanqiao
 * @date 2023-06-14
 */
public class TenantCategory extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    public static final String BIGTABLENAME = "_CATEGORY";

    public TenantCategory() {
        /*String tenantCode = SecurityUtils.getTenantCode();
        if(StringUtils.isEmpty(tenantCode)){
            tenantCode = SecurityUtils.getLoginUser().getUser().getTenantCode();
            if (StringUtils.isEmpty(tenantCode)){
                throw new ServiceException("TenantCode is null");
            }
        }*/
        if(SecurityUtils.getLoginUser() !=null){
            String tenantCode = SecurityUtils.getTenantCode();
            if(StringUtils.isEmpty(tenantCode)){
                if(SecurityUtils.getLoginUser() != null){
                    tenantCode = SecurityUtils.getLoginUser().getUser().getTenantCode();
                }
            /*if (StringUtils.isEmpty(tenantCode)){
                throw new ServiceException("TenantCode is null");
            }*/
            }
            this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
        }


    }

    /** 主键 */
    @IdAnnotation
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long id;

    /** 父级ID */
    @Excel(name = "父级ID")
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long parentId;

    /** 元数据方案ID */
    @Excel(name = "元数据方案ID")
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long groupId;

    /** 门类名称 */
    @Excel(name = "门类名称")
    private String name;

    /** 门类类型 */
    @Excel(name = "门类类型")
    private Integer type;

    /** 整理方式 */
    @Excel(name = "整理方式")
    private String storeType;

    /** 上架方式 */
    @Excel(name = "上架方式")
    private Integer storeMode;

    /** 门类代码 */
    @Excel(name = "门类代码")
    private String code;

    /** 项目表名 */
    @Excel(name = "项目表名")
    private String itemTableName;

    /** 卷表名 */
    @Excel(name = "卷表名")
    private String folderTableName;

    /** 件表名 */
    @Excel(name = "件表名")
    private String fileTableName;

    /** 电子文件表名 */
    @Excel(name = "电子文件表名")
    private String efileTableName;

    /** 删除 */
    @Excel(name = "删除")
    private Integer isDel;

    /** 创建人ID */
    @Excel(name = "创建人ID")
    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long createId;

    /** 全宗号 */
    @Excel(name = "全宗号")
    private String fondsCode;

    /** 原文类型 */
    @Excel(name = "原文类型")
    private String fileTypes;

    private String tableName;

    @Excel(name = "排序")
    private Integer orderNo;

    public Integer getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(Integer orderNo) {
        this.orderNo = orderNo;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setParentId(Long parentId)
    {
        this.parentId = parentId;
    }

    public Long getParentId()
    {
        return parentId;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getName()
    {
        return name;
    }
    public void setType(Integer type)
    {
        this.type = type;
    }

    public Integer getType()
    {
        return type;
    }
    public void setStoreType(String storeType)
    {
        this.storeType = storeType;
    }

    public String getStoreType()
    {
        return storeType;
    }
    public void setStoreMode(Integer storeMode)
    {
        this.storeMode = storeMode;
    }

    public Integer getStoreMode()
    {
        return storeMode;
    }
    public void setCode(String code)
    {
        this.code = code;
    }

    public String getCode()
    {
        return code;
    }
    public void setItemTableName(String itemTableName)
    {
        this.itemTableName = itemTableName;
    }

    public String getItemTableName()
    {
        return itemTableName;
    }
    public void setFolderTableName(String folderTableName)
    {
        this.folderTableName = folderTableName;
    }

    public String getFolderTableName()
    {
        return folderTableName;
    }
    public void setFileTableName(String fileTableName)
    {
        this.fileTableName = fileTableName;
    }

    public String getFileTableName()
    {
        return fileTableName;
    }
    public void setEfileTableName(String efileTableName)
    {
        this.efileTableName = efileTableName;
    }

    public String getEfileTableName()
    {
        return efileTableName;
    }
    public void setIsDel(Integer isDel)
    {
        this.isDel = isDel;
    }

    public Integer getIsDel()
    {
        return isDel;
    }
    public void setCreateId(Long createId)
    {
        this.createId = createId;
    }

    public Long getCreateId()
    {
        return createId;
    }
    public void setFondsCode(String fondsCode)
    {
        this.fondsCode = fondsCode;
    }

    public String getFondsCode()
    {
        return fondsCode;
    }
    public void setFileTypes(String fileTypes)
    {
        this.fileTypes = fileTypes;
    }

    public String getFileTypes()
    {
        return fileTypes;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    @Override
    public String toString() {
        return "TenantCategory{" +
                "id=" + id +
                ", parentId=" + parentId +
                ", groupId=" + groupId +
                ", name='" + name + '\'' +
                ", type=" + type +
                ", storeType='" + storeType + '\'' +
                ", storeMode=" + storeMode +
                ", code='" + code + '\'' +
                ", itemTableName='" + itemTableName + '\'' +
                ", folderTableName='" + folderTableName + '\'' +
                ", fileTableName='" + fileTableName + '\'' +
                ", efileTableName='" + efileTableName + '\'' +
                ", isDel=" + isDel +
                ", createId=" + createId +
                ", fondsCode='" + fondsCode + '\'' +
                ", fileTypes='" + fileTypes + '\'' +
                ", tableName='" + tableName + '\'' +
                ", orderNo=" + orderNo +
                '}';
    }
}
